package com.xiyu.service.controller.admin.fee;
import com.xiyu.service.vo.fee.feeCategory.FeeCategoryGetByTypeOutput;
import com.xiyu.service.vo.fee.feeCategory.FeeCategoryListQueryOutput;
import com.xiyu.service.vo.fee.feeCategory.FeeCategoryGetFirstFeeOutput;
import com.xiyu.service.vo.fee.feeCategory.FeeCategoryGetOutput;
import com.xiyu.service.vo.fee.feeCategory.FeeCategoryUpdateInput;
import com.xiyu.service.vo.fee.feeCategory.FeeCategoryCreateInput;
import com.xiyu.service.vo.fee.feeCategory.FeeCategoryQueryOutput;
import com.xiyu.service.vo.fee.feeCategory.FeeCategoryQueryInput;
import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import jakarta.validation.constraints.*;
import jakarta.validation.*;
import jakarta.servlet.http.*;
import java.util.*;

import com.xiyu.service.framework.web.web.core.pojo.PageResult;
import com.xiyu.service.framework.web.web.core.pojo.CommonResult;
import static com.xiyu.service.framework.web.web.core.pojo.CommonResult.success;

import com.xiyu.service.framework.excel.core.util.ExcelUtils;

import com.xiyu.service.framework.operateLog.core.annotations.OperateLog;
import static com.xiyu.service.framework.operateLog.core.enums.OperateTypeEnum.*;

import com.xiyu.service.service.fee.FeeCategoryService;

@Tag(name = "费用类别")
@RestController
@RequestMapping("/fee/fee-category")
@Validated
public class FeeCategoryController {

    @Resource
    private FeeCategoryService feeCategoryService;

    @GetMapping("/query")
    @Operation(summary = "分页查询费用类别")
    @PreAuthorize("@ss.hasPermission('fee:category:query')")
    public CommonResult<PageResult<FeeCategoryQueryOutput>> query(@Valid FeeCategoryQueryInput inputVO) {
        return success(feeCategoryService.query(inputVO));
    }

    @PostMapping("/create")
    @Operation(summary = "新建费类别")
    @PreAuthorize("@ss.hasPermission('fee:category:create')")
    public CommonResult<Long> create(@Valid @RequestBody FeeCategoryCreateInput inputVO) {
        return success(feeCategoryService.create(inputVO));
    }

    @GetMapping("/update")
    @Operation(summary = "更新费用类别")
    @PreAuthorize("@ss.hasPermission('fee:category:update')")
    public CommonResult<Boolean> update(@Valid FeeCategoryUpdateInput inputVO) {
        return success(feeCategoryService.update(inputVO));
    }

    @DeleteMapping("/deleted")
    @Operation(summary = "删除费用类别")
    @PreAuthorize("@ss.hasPermission('fee:category:deleted')")
    @Parameter(name = "id", description = "主键ID", example = "")
    public CommonResult<Boolean> deleted(@RequestParam("id") Long id) {
        return success(feeCategoryService.deleted(id));
    }

    @GetMapping("/get")
    @Operation(summary = "获取单个费用类型")
    @Parameter(name = "id", description = "主键ID", example = "")
    public CommonResult<FeeCategoryGetOutput> get(@RequestParam("id") Long id) {
        return success(feeCategoryService.get(id));
    }

    @GetMapping("/get-first-fee")
    @Operation(summary = "获取初始收费类型")
    public CommonResult<List<FeeCategoryGetFirstFeeOutput>> getFirstFee() {
        return success(feeCategoryService.getFirstFee());
    }

    @GetMapping("/list-query")
    @Operation(summary = "查询费用类别")
    public CommonResult<List<FeeCategoryListQueryOutput>> listQuery() {
        return success(feeCategoryService.listQuery());
    }

    @GetMapping("/get-by-type")
    @Operation(summary = "根据类型获取费用类别")
    @Parameter(name = "type", description = "费用类型", example = "")
    public CommonResult<List<FeeCategoryGetByTypeOutput>> getByType(@RequestParam("type") Integer type) {
        return success(feeCategoryService.getByType(type));
    }

}
